	#include <cmath>
	#include <iostream>
	#include <vector>
	#include <queue>
	#include <algorithm>
	#include <map>
	#include <set>
	#include <cstring>
	#define endl "\n"
	using namespace std;
	int n, a[5005], b[5005],y=0;
	int main()
	{	
		cin >> n;
		for (int i = 1; i <= n; i++)
		{
			cin >> a[i];
		}
		b[1] = 1;
		for (int i = 1; i <=n; i++)
		{
			for (int j = 1; j < i; j++)
			{
				if (a[i] > a[j]&&b[i]<b[j]+1)
				{
					b[i] = b[j]+1;
				}
			}
			
		}
		for (int i = 1; i <= n; i++)
		{
			y = max(b[i], y);
		}
		cout << y << endl;
		return 0;
	}